{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<style>
    .layui-laydate-header{
        display: none;
    }
    .layui-laydate-content> table>thead{
        display: none;
    }
    .laydate-day-prev{
        display: none;
    }
    .laydate-day-next{
        display: none;
    }
</style>
<form class="layui-form p-4">
    <h3 class="pb-3">功能菜单/节点</h3>
    <table class="layui-table layui-table-form">
        <tr>
            <td class="layui-td-gray-2">客户名称<font>*</font>
            </td>
            <td>
                <input type="text" name="punterName" value="{$detail.punterName|default=''}"   lay-verify="required" autocomplete="off" placeholder="请输入"
                       lay-reqText="请输入" class="layui-input">
            </td>


            <td class="layui-td-gray">线索联系人姓名<font>*</font>
            </td>
            <td>
                <input type="text" name="contactName" value="{$detail.contactName|default=''}"   lay-verify="required" autocomplete="off" placeholder="请输入"
                       lay-reqText="请输入" class="layui-input">
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">线索联系人电话<font>*</font>
            </td>
            <td>
                <input type="text" name="contactPhone" value="{$detail.contactPhone|default=''}" lay-verify="required|phone"   autocomplete="off" placeholder="请输入"
                       lay-reqText="请输入" class="layui-input">
            </td>
            <td class="layui-td-gray-2">线索联系人职位<font>*</font>
            </td>
            <td>
                <input type="text" name="contactJob" value="{$detail.contactJob|default=''}" lay-verify="required"  autocomplete="off" placeholder="请输入"
                       lay-reqText="请输入" class="layui-input">
            </td>
            </tr>
            <tr>
<!--            <td class="layui-td-gray">沟通时间<font>*</font>-->
<!--            </td>-->
<!--            <td>-->
<!--                <input type="text"  name="gTime" id="vTime" readonly value="{$detail.gTime|default=''}" lay-verify="required"    autocomplete="off" placeholder="请输入"-->
<!--                       lay-reqText="请输入" class="layui-input">-->
<!--            </td>-->

                <td class="layui-td-gray-2">线索内容<font>*</font>
                </td>
                <td colspan="">
                    <input name="content"  class="layui-input" value="{$detail.content|default=''}"></input>
                </td>
                <td class="layui-td-gray">负责人<font>*</font>
                </td>
                <td>
                    <select name="fzId" xm-select="selectId" lay-search>
                        {volist name="adminList" id= 'al'}
                        <option value="{$al.id}" {if isset($detail.fzId)&&$detail.fzId==$al.id} selected {/if}>{$al.name}</option>
                        {/volist}
                    </select>
                </td>
        </tr>
        <tr>


<!--            <td class="layui-td-gray-2">后续跟进计划<font>*</font>-->
<!--            </td>-->
<!--            <td>-->
<!--                <input type="text" name="applane" value="{$detail.applane|default=''}" lay-verify="required"  autocomplete="off" placeholder="请输入"-->
<!--                       lay-reqText="请输入" class="layui-input">-->
<!--            </td>-->
            <td colspan="4"></td>
        </tr>
        <tr>
            <td colspan="4">
                <h4>沟通记录</h4>
            <table class="layui-table">
               <thead>
               <tr>
                   <th>沟通时间</th>
                   <th>沟通内容</th>
                   <th>操作 <a href="javascript:" class="layui-btn layui-btn-xs layui-btn-primary" onclick="addMx()">添加</a></th>
               </tr>
               </thead>
                <tbody id="mxBody">

                {if $gtMxList}
                {volist name='gtMxList' id='ml'}
                <tr>
                    <td>
                        <input type="hidden" name="mx[mxId][]" value="{$ml.id}">
                        <input type="text" name="mx[gtTime][]" value="{$ml.gtTime}" readonly class="layui-input mxGtTime" lay-verify="required"  autocomplete="off" placeholder="请输入">
                    </td>
                    <td><input type="text" name="mx[gtContent][]"value="{$ml.gtContent}" class="layui-input" lay-verify="required"  autocomplete="off" placeholder="请输入"></td>
                    <td><a href="javascript:" class="layui-btn layui-btn-danger layui-btn-xs" onclick="removeTr(this,'{$ml.id}')">删除</a> </td>
                </tr>
                {/volist}
                {else}
                <tr>
                    <td>
                        <input type="hidden" name="mx[mxId][]">
                        <input type="text" name="mx[gtTime][]" value="{$thisDate}" readonly class="layui-input mxGtTime" lay-verify="required"  autocomplete="off" placeholder="请输入">
                    </td>
                    <td><input type="text" name="mx[gtContent][]" class="layui-input" lay-verify="required"  autocomplete="off" placeholder="请输入"></td>
                    <td><a href="javascript:" class="layui-btn layui-btn-danger layui-btn-xs layui-disabled" onclick="">删除</a> </td>
                </tr>
                {/if}

                </tbody>
            </table>
            </td>
        </tr>
        <tr>



        </tr>
    </table>
    {if !isset($detail.status)||$detail.status==1}
    <div class="py-3">
        <input type="hidden" name="id" value="{$id}">
        <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">保存</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
    {/if}
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}

<script>
    const moduleInit = ['tool'];
    function gouguInit() {
        var form = layui.form,tool=layui.tool,level=0,laydate = layui.laydate;
        //监听提交
        form.on('submit(webform)', function (data) {
            let callback = function (e) {
                layer.msg(e.msg);
                if (e.code == 0) {
                    setTimeout(function(){
                        parent.parent.location.reload();
                    },1000);
                }
            }
            tool.post("{:url('add')}", data.field, callback);
            return false;
        });
        laydate.render({
            elem: '.mxGtTime' ,// 指定元素
            type:'datetime',
        });
    }
</script>

<script>
    function addMx(){
        let str='    <tr>\n' +
            '                    <td>\n' +
            '                        <input type="hidden" name="mx[mxId][]">\n' +
            '                        <input type="text" name="mx[gtTime][]" readonly class="layui-input mxGtTime" lay-verify="required" value="{$thisDate}"  autocomplete="off" placeholder="请输入">\n' +
            '                    </td>\n' +
            '                    <td><input type="text" name="mx[gtContent][]" class="layui-input" lay-verify="required"  autocomplete="off" placeholder="请输入"></td>\n' +
            '                    <td><a href="javascript:" class="layui-btn layui-btn-danger layui-btn-xs" onclick="removeTr(this)">删除</a> </td>\n' +
            '                </tr>';
        $("#mxBody").append(str)
        layui.laydate.render({
            elem: '.mxGtTime' ,// 指定元素
            type:'datetime',
        });
        layui.form.render();
    }
    function removeTr(e, id = '') {
        if (id != '') {
            httpRequest("{:url('removeMx')}", {id: id}, function (res) {
                if (res.code == 0) {
                    $(e).parent().parent().remove()
                }
            })
        } else {
            $(e).parent().parent().remove()
        }

    }
</script>
{/block}
<!-- /脚本 -->